<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>编辑灵敏度</title>
    <style>
        .two-part-label{
            width: 300px !important;
        }
    </style>
</head>
<body>
<script type="text/html" id="form">
    <input type="hidden" name="id" value="{{ d.id }}" />
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <blockquote class="layui-elem-quote">信息</blockquote>

                <div class="layui-form-item">
                    <label class="layui-form-label">作者</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="author_id"
                             data-sourceType="route"
                             data-source="/admin.fire.author/author"
                             data-params='{"author_id": {{d.author_id}},"search_param":{"type":{"value":1,"condition":"="}}}'
                             data-textField="author_name"
                             data-valueField="id"
                             data-paging="true"
                             data-radio="true"
                             data-layVerify="required"
                             data-direction="down"
                             data-selected="{{ d.author_id }}"
                        ></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">设备</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="device"
                             data-sourceType="data"
                             data-radio="true"
                             data-source="[{name:'手机',value:'手机'},{name:'平板',value:'平板'}]"
                             data-selected="{{=d.device}}"
                        ></div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">手指</label>
                    <div class="layui-input-block">
                        <div class="xmSelect"
                             data-name="finger"
                             data-sourceType="data"
                             data-radio="true"
                             data-source="[{name:'二指',value:'二指'},{name:'三指',value:'三指'},{name:'四指',value:'四指'},{name:'多指',value:'多指'}]"
                             data-selected="{{=d.finger}}"
                        ></div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">灵敏度码</label>
                    <div class="layui-input-block">
                        <input type="text" id="code" name="code" onblur="checkCode(this.value,this.node)" class="layui-input" lay-verify="required|code" lay-reqtext="请输入灵敏度码" placeholder="请输入灵敏度码" value="{{ d.code }}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">开镜</label>
                    <div class="layui-input-block">
                        <input type="text"  name="mirror_remark" class="layui-input"  placeholder="请输入开镜描述" value="{{ d.mirror_remark }}">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">陀螺仪</label>
                    <div class="layui-input-block">
                        <input type="text"  name="gyroscope_remark" class="layui-input"  placeholder="请输入陀螺仪描述" value="{{ d.gyroscope_remark }}">
                    </div>
                </div>

                <blockquote class="layui-elem-quote">手搓</blockquote>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">转向灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint1(this.value,'hand-1')" id="hand-1" name="hand-1" value="{{ d.hand[0] }}" lay-verify="required|number|point1" max="300" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">开火灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint1(this.value,'hand-2')" id="hand-2"  name="hand-2" value="{{ d.hand[1] }}" lay-verify="required|number|point1" max="300" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">狙击一倍灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint1(this.value,'hand-3')" id="hand-3"  name="hand-3" value="{{ d.hand[2] }}" lay-verify="required|number|point1" max="300" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">狙击二倍灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint1(this.value,'hand-4')" id="hand-4"  name="hand-4" value="{{ d.hand[3] }}" lay-verify="required|number|point1" max="300" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">非狙开镜灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint1(this.value,'hand-5')" id="hand-5"  name="hand-5" value="{{ d.hand[4] }}" lay-verify="required|number|point1" max="300" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">刀战灵敏度倍率</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint1(this.value,'hand-6')" id="hand-6"  name="hand-6" value="{{ d.hand[5] }}" lay-verify="required|number|point1" max="300" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">投掷力度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint1(this.value,'hand-7')" id="hand-7"  name="hand-7" value="{{ d.hand[6] }}" lay-verify="required|number|point1" max="300" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">第一人称视野</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint1(this.value,'hand-8')" id="hand-8"  name="hand-8" value="{{ d.hand[7] }}" lay-verify="required|number|point1" max="300" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                </div>


                <blockquote class="layui-elem-quote">陀螺仪</blockquote>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">X轴灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint2(this.value,'gyroscope-1')" id="gyroscope-1" name="gyroscope-1" value="{{ d.gyroscope[0] }}" lay-verify="required|number|point2" max="400" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">Y轴灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint2(this.value,'gyroscope-2')" id="gyroscope-2" name="gyroscope-2" value="{{ d.gyroscope[1] }}" lay-verify="required|number|point2" max="400" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">狙击一倍灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint2(this.value,'gyroscope-3')" id="gyroscope-3" name="gyroscope-3" value="{{ d.gyroscope[2] }}" lay-verify="required|number|point2" max="400" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">狙击二倍灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint2(this.value,'gyroscope-4')" id="gyroscope-4" name="gyroscope-4" value="{{ d.gyroscope[3] }}" lay-verify="required|number|point2" max="400" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label two-part-label">非狙开镜灵敏度</label>
                        <div class="layui-input-inline">
                            <input type="number" onblur="checkPoint2(this.value,'gyroscope-5')" id="gyroscope-5" name="gyroscope-5" value="{{ d.gyroscope[4] }}" lay-verify="required|number|point2" max="400" autocomplete="off" placeholder="请输入百分比数值"  class="layui-input">
                        </div>
                    </div>
                </div>

                <input type="hidden" name="type" value="1" />
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="laytp-form">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</script>
<form class="layui-form" lay-filter="layui-form"></form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>
    function checkCode(value,node){
        if(value.length != 22){
            layer.tips('灵敏度码格式不正确',"#code",{
                tips:[3,'red']
            })
            $('#code').focus();
        }

    }


    function checkPoint1(value,node){
        if(value>300){
            layer.tips('最大值为300%','#'+node,{
                tips:[3,'red']
            })
            $('#'+node).focus();
        }

    }


    function checkPoint2(value,node){
        if(value>400){
            layer.tips('最大值为400%','#'+node,{
                tips:[3,'red']
            })
            $('#'+node).focus();
        }

    }
    layui.use(['laytp'],function(){
        let form = layui.form;
        let $ = layui.jquery;
        //获取参数ID
        var id = facade.getUrlParam('id');
        if(!id){
            facade.error('参数ID不能为空');
            return false;
        }

        //获取数据，渲染到对应的节点上
        facade.ajax({
            route: "/admin.fire.record/info",
            data: {id: id},
            successAlert: false,
            showLoading: true
        }).done(function(res){
            if(res.code === 0){
                layui.laytpl($("#form").html()).render(res.data,function(string){
                    $("form").html(string);
                    layui.laytpForm.render();
                    form.render();
                });
            }
        });
        layui.form.verify({
            point1:function(value,item){
                if(value > 300){
                    return '最大值为300%';
                }
            },
            point2:function(value,item){
                if(value > 400){
                    return '最大值为400%';
                }
            },
            code:function(value,item){
                if(value.length != 22 ){
                    return '灵敏度码格式不正确';
                }
            }
        });

        form.on('submit(laytp-form)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.fire.record/edit',
                data:data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>